<template>
  <div class="card">
    <div class="triangle" @click="insertNoFeel">
      <van-icon name="cross" />
    </div>
    <div class="performanceInfo-layout">
      <div class="info">
        <div class="user">
          <div class="userInfo">
            <div class="header">
              <img :src="form.userIcon">
            </div>
          </div>
          <div class="userName">
            <p>{{form.userName}}</p>
            <van-rate v-model="form.grade"
                      v-if="form.grade>0"
                      :allow-half="true"
                      :readonly="true"
                      void-color="#E5E5E5"
                      void-icon="star"
                      :size="14" />
            <div class="fz5 wordstxt"
                 style="margin-top:0.08rem"
                 v-if="form.workingYears&&form.grade==0">{{form.workingYears}}年工作经验</div>
          </div>
        </div>
        <div class="price-info">
          <p class="lingThrough">原¥{{form.originalPrice}}/张</p>
          <div>
            <span class="limitTime">{{form.ltTime}}小时内</span>
            <span class="simple">¥</span>
            <span class="num fz4">{{form.ltTimePrice}}</span>
            <span class="unit">/张</span>
          </div>
          <p>超时¥{{form.gtTimePrice}}/小时</p>
        </div>
      </div>
    </div>
    <div class="photo">
      <div v-for="(item,index) in form.preview"
           :key="index">
        <img :src="item">
      </div>
    </div>
    <div class="bookTime flex"
         v-if="form.calendars.length>0">
      <div class="title">档期</div>
      <div :class="{'timeList':item.isReservation==0,'timeList1':item.isReservation==1}"
           v-show="index<5"
           v-for="(item,index) in form.calendars">
        <span v-if="index<3">{{index | getdate1}}</span>
        <span v-else>{{item.dateTime | getdate}}</span>
      </div>
      <div class="appointment bgprimary wordsWrite fz4"
           @click="updatePerformanceist">选择</div>
    </div>
  </div>
</template>
<script>
export default {
  props: ["form"],
  data() {
    return {
      imgList: [
        {
          imgReq: require("@/assets/img/performance/homePage/test.png")
        },
        {
          imgReq: require("@/assets/img/performance/homePage/test.png")
        },
        {
          imgReq: require("@/assets/img/performance/homePage/test.png")
        },
        {
          imgReq: require("@/assets/img/performance/homePage/test.png")
        }
      ]
    };
  },
  mounted() {
    // this.get_timeList();
  },
  methods: {
    updatePerformanceist() {
      this.$emit("updatePerformanceist");
    },
    insertNoFeel() {
      this.$emit("insertBlackList");
    }
    //前五天数据
    // get_timeList() {
    //   let date,
    //     timeList = [
    //       { date: "", isReservation: 0 },
    //       { date: "", isReservation: 0 },
    //       { date: "", isReservation: 0 },
    //       { date: "", isReservation: 0 },
    //       { date: "", isReservation: 0 }
    //     ],
    //     form = {},
    //     i = 3;
    //   for (i; i < 5; i++) {
    //     date = new Date(
    //       new Date().getTime() + 24 * 60 * 60 * 1000 * i
    //     ).getDate();
    //     form = { date, choose: true };
    //     timeList.fill(form, i, i + 1);
    //   }
    //   this.timeList = timeList;
    // }
  },
  filters: {
    getdate(date) {
      return date.slice(date.length - 2, date.length);
    },
    getdate1(date) {
      switch (date) {
        case 0:
          return "今";
          break;
        case 1:
          return "明";
          break;
        case 2:
          return "后";
          break;
        default:
          break;
      }
    }
  }
};
</script>

<style lang="scss" scoped>
.card {
  margin: 0.16rem 0.24rem;
  border-radius: 0.1rem;
  background: #ffffff;
  z-index: 1;
  .triangle {
    width: 0;
    height: 0;
    border: 0.37rem solid #d8d8d8;
    border-right: 0.37rem solid transparent;
    border-bottom: 0.37rem solid transparent;
    border-top-left-radius: 0.3em;
    position: absolute;
    .van-icon {
      position: absolute;
      margin-top: -0.25rem;
      margin-left: -0.25rem;
      font-size: 0.18rem;
      font-weight: bold;
      color: #aaaaaa;
    }
  }
  .performanceInfo-layout {
    padding: 0.4rem 0.24rem;
    .info {
      display: flex;
      justify-content: space-between;
      .user {
        display: flex;
        align-items: center;
        .userInfo {
          .header {
            width: 1rem;
            height: 1rem;
            // border: 0.01rem solid red;
            display: flex;
            align-items: center;
            justify-content: center;
            img {
              width: 1rem;
              height: 1rem;
            }
          }
        }
        .userName {
          width: 2rem;
          margin-left: 0.2rem;
          display: flex;
          flex-direction: column;
          justify-content: space-between;
          padding: 0.32rem 0;
          p {
            font-size: 0.32rem;
            font-weight: 600;
            color: #282828;
            word-wrap: normal;
            text-overflow: ellipsis;
            white-space: nowrap;
            overflow: hidden;
          }
          .van-rate {
            .van-rate__item {
              i {
                font-size: 0.2rem !important;
                margin-top: 0.1rem;
              }
            }
          }
        }
      }
      .price-info {
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        align-items: flex-end;
        .lingThrough {
          text-decoration: line-through;
        }
        p {
          font-size: 0.24rem;
          color: #959595;
          font-weight: 400;
        }
        .limitTime {
          color: #ffffff;
          font-size: 0.2rem;
          background: #5e8efe;
          padding: 0.03rem;
          border-radius: 0.04rem;
        }
        .simple {
          color: #5e8efe;
          font-size: 0.24rem;
          margin: 0 0.09rem;
        }
        .num {
          // font-size: 0.36rem;
          color: #5e8efe;
        }
        .unit {
          font-size: 0.24rem;
          color: #959595;
        }
      }
    }
  }
  .photo {
    padding: 0 0.24rem;
    display: flex;
    height: 1.56rem;
    > div {
      margin-right: 0.1rem;
      &:last-child {
        margin-right: 0;
      }
      img {
        width: 1.56rem;
        height: 1.56rem;
      }
    }
  }
  .bookTime {
    padding: 0.3rem 0.24rem;
    align-items: center;
    .title {
      line-height: 0.56rem;
      margin-right: 0.2rem;
    }
    /* 有档期 */
    .timeList {
      text-align: center;
      width: 0.56rem;
      height: 0.56rem;
      line-height: 0.56rem;
      border: 1px solid #dddddd;
      border-radius: 90px;
      margin-right: 0.1rem;
    }
    /* 无档期 */
    .timeList1 {
      text-align: center;
      width: 0.56rem;
      height: 0.56rem;
      line-height: 0.56rem;
      border-radius: 90px;
      margin-right: 0.1rem;
      background: #f5f5f5;
      color: #cccccc;
    }
    .appointment {
      position: absolute;
      right: 0.48rem;
      width: 1.8rem;
      height: 0.88rem;
      text-align: center;
      line-height: 0.88rem;
      border-radius: 0.1rem;
    }
  }
}
</style>
